<style>
tr.striped {
        background-color: #0ec0cc;
}
</style>
<script type="text/javascript">
function bulkModule(formId, mRowId, mStatus, mClass){
		bFormId = "#" + formId;
		bRowId = "#" + mRowId;
		bStatus = "#" + mStatus;
		bIdClass = "." + mClass;

		$(bFormId).ajaxForm({
				dataType:  'json',
				success: function(json){
			
				if(json.bulkaction == 'delete')
				{        
//					if(json.success != 1)
//					{
//						alert('Not allowed to delete this user information. Check if your session expired');
//						return;
//					}
					$.each(json.ids, function(i,id){
						$(bRowId + id).css('background-color','red').fadeOut(2000).remove();
						console.log("Removing place-box-" + id);        
					});
				}
				else if(json.success == '1'){
					if(json.bulkaction == 'status')
					{
						if(json.status == 'deleted' || json.status == 'spam'){
							$.each(json.ids, function(i,id){
								$(bRowId + id).css('background-color','blue').fadeOut(2000);
								$(bIdClass + ":checkbox:checked").click();
							});
						}
						else
						{
							$.each(json.ids, function(i,id){
								$(bIdClass + ":checkbox:checked").click();
								$(bStatus + id).html(json.status);
							});
						}
					}
					else
						alert('fall');
				}
				//set list null
				json.ids = null;
			}
		});
	}
	
        $(function(){
                bulkModule("tour-form", "tour-row-", "tour-status-", "tourIdClass");
                
                $("a[name^=tour-delete]").click(function(e){
					id = this.name.split('-')[2];
					$.getJSON("/en/tour/ajax/delete-tour", {'id': id},
							function(json) {
						if (json.success == 1){
							$("#tour-row-" + id).fadeOut(2000); //2 seconds
						}
						else
						{
							alert('Not allowed to delete this user information. Check if your session expired');
							$("#delete-error-" + id).show().html("Could not delete");;
							return;
						}
					});
					return false;
				});
        });
        
</script>

<?
	$sess = new Zend_Session_Namespace(CLU_NS);
?>
<body>
<form id ="tour-form" action="/en/tour/ajax/bulk-tour" method="POST">
<!--  use action in common module -->
<table border = '1' width='100%' id = "show-table">
	<tr align ="center">
		<td></td>
		<td><?=t(27) ?> </td>
		<td><?=t(810) ?></td>
		<td><?=t(811) ?></td>
		<td><?=t(812) ?></td>
		<td><?=t(813) ?></td>
		<td><?=t(814) ?></td>
		<td><?=t(815) ?></td>
		<td><?=t(816) ?></td>
		<td><?=t(2) ?></td>
		<td><?=t(83) ?></td>
		<td><?=t(84) ?></td>
		<td><?=t(29) ?></td>
	</tr>
	
	<? foreach ($this->tList as $row) :?>
	<!--<//?$row = $this->m->transformToFormArray($row); ?>-->
	<tr id="tour-row-<?=$row['id']?>">
		<td width = "10" align="center" valign = "top">
			<input type="checkbox" value="<?=$row['id'] ?>" class="tourIdClass" name="tour_ids[<?=$row['id'] ?>]"/>
		</td>
		<td> #<?=$row['id']?></td>
		<td>
			<a href="<?=$this->hvnUrl(array('module' => 'tour', 'action' => 'view'))?>?id=<?=$row['id']?>" > <?=$row['name'] ?></a>
		</td>
		<td><?=$row['price'] ?></td>
		<td><?=$row['price_currency'] ?></td>
		<td><?=$row['total_duration'] ?></td>
		<td><?=$row['departure_date'] ?></td>
		<td> <?=$row['return_date'] ?> </td>
		<td> <?=$row['category'] ?> </td>
		<td id= "tour-status-<?=$row['id'] ?>"> <?=$row['status'] ?> </td>
		<td> <?=$row['poster_id'] ?> </td>
		<td> <?=date("d.m.y", $row['post_time'])  ?> </td>
    	<td width="20%"><a href="<?=$this->hvnUrl(array('module' => 'tour', 'action' => 'edit'))?>?id=<?=$row['id']?>">edit</a>
    	<a href="javascript:void()" name="tour-delete-<?=$row['id']?>">delete</a>
        <span id="delete-error-<?=$row['id']?>"></span>
        </td> 
	</tr>
	<?endforeach ?>
</table>

<br />
<div style="width:100%;float: right" id = "paging">
<?= $this->paginationControl($this->paginator, 'Sliding', 'commonTheme/nolang/index/admin_pagination_control.phtml'); ?>
</div>
<div  style="background-color:#EEEEEE">
<?=t(30) ?>: 
<br/> 
<select name='bulkaction' id ="bulk" >

<?if(strpos ($sess->userPermissions, 'administer tour') ):?>
<option value='delete'> <?=t(31) ?> </option>
<?endif ?>
<option value='status'> <?=t(32) ?> </option>
</select>

<select name='changestatus' id ="changeStatus" style=" display:none">
<option value='featured'> <?=t(33) ?> </option>
<option value='published'> <?=t(34) ?> </option>
<option value='queued'> <?=t(35) ?> </option>
<option value='unpublished'> <?=t(36) ?> </option>
<option value='deleted'> <?=t(37) ?> </option>
</select>
<input type="submit" value="Apply" id="bulk-submit" name="op"/>
</div>
</form>


</body>